<template>
  <div>
    <el-card>
      <el-form>
        <el-form-item label="一级分类" width="200px">
          <el-select v-model="useCategorizeStore.infoId" @change="idGo">
            <!-- 对于labei，用于下拉菜单展示数据，对于value，用于下拉菜单收集数据 -->
            <el-option
              v-for="C1 in useCategorizeStore.info"
              :label="C1.name"
              :key="C1.id"
              :value="C1.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="二级分类">
          <el-select v-model="useCategorizeStore.infoId2" @change="idGo2">
            <el-option
              v-for="C2 in useCategorizeStore.info2"
              :label="C2.name"
              :key="C2.id"
              :value="C2.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="三级分类">
          <el-select v-model="useCategorizeStore.infoId3">
            <el-option
              v-for="C3 in useCategorizeStore.info3"
              :label="C3.name"
              :key="C3.id"
              :value="C3.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script lang="ts">
export default {
  name: 'categorizeIndex',
}
</script>
<script setup lang="ts">
import categorizeStore from '../../store/modules/categorize'
import { onMounted } from 'vue'
const useCategorizeStore = categorizeStore()

function getC1() {
  useCategorizeStore.getC1()
}
function idGo() {
  useCategorizeStore.getC2()
  useCategorizeStore.infoId2 = ''
  useCategorizeStore.infoId3 = ''
}
function idGo2() {
  useCategorizeStore.getC3()
  useCategorizeStore.infoId3 = ''
}
onMounted(() => {
  getC1()
})
</script>

<style>
.el-select {
  --el-select-width: 220px;
}
</style>